#include <vector>
#include <map>

using std::map;
using std::vector;

class Solution
{
public:
    vector<int> twoSum(vector<int>& sums, int target) {
        map<int, int> array;
        vector<int> result(2, -1);
        if(sums.size() < 2)
            return result;
        else {
            for (int i = 0; i < sums.size(); i++) {
                array.insert(sums.at(i), i);
            }
            for (int i = 0; i < sums.size(); i++) {
                if(array.count(target-sums.at(i)) > 0 && array.at(target-sums.at(i)) != i) {
                    vector<int>::iterator ite;
                    ite = result.begin();
                    *ite = i;
                    *(ite + 1) = array.at(target - sums.at(i));
                    break;
                }
            }
        }
    }
};